﻿<Page x:Class="testProject.Page1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
      xmlns:local="clr-namespace:testProject"
      d:DesignHeight="300" d:DesignWidth="300"
      FocusManager.FocusedElement="{Binding RelativeSource={x:Static RelativeSource.Self}, Mode=OneTime}"
    Title="Page1">
    <Page.Resources>
        <DataTemplate x:Key="testTemplate">
            <StackPanel Height="100">
                <!--<Button Command="{Binding Path=DataContext.SaveCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Page}}" Content="Copy"/>
                    <TextBlock Text="{Binding}"
                               helper:MyTest.TestParameter="{Binding}"
                               helper:MyTest.Test="{Binding Path=DataContext.MouseEnterCommande,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Page}}" >
                        
                    </TextBlock>-->
                <!--<TextBlock Text="{Binding}"> 
                        <TextBlock.ContextMenu>
                        <ContextMenu>
                            <MenuItem Command="{Binding Path=CopyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}},Mode=TwoWay,Converter={StaticResource CommandConverter}}" CommandParameter="hello" Header="Copy"/>
                        </ContextMenu>
                         </TextBlock.ContextMenu>
                    </TextBlock>-->
                <Menu>
                    <MenuItem Command="{Binding Path=CopyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}},Mode=TwoWay,Converter={StaticResource CommandConverter}}" CommandParameter="hello" Header="Copy"/>
                </Menu>

                <TextBlock Text="right click me to see what happend">
                        <TextBlock.ContextMenu>
                            <ContextMenu>
                                <MenuItem Command="{Binding Path=CopyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}},Mode=TwoWay}"
                                    CommandParameter="hello"
                                    Header="CopyCommand"/>
                                    <!--Command=""-->
                            </ContextMenu>
                        </TextBlock.ContextMenu>
                </TextBlock>
                <TextBlock>
                        <Hyperlink Command="Print" CommandParameter="Hyperlink" >Print</Hyperlink>
                </TextBlock>
                <Button Command="{Binding Path=DataContext.CopyCommand,
                        RelativeSource={RelativeSource Mode=FindAncestor,
                        AncestorType=Page},
                        Mode=TwoWay}" CommandParameter="hello" Content="Copy"/>
                <TextBlock Text="{Binding Path=LoadTime,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Page}}"/>
            </StackPanel>
        </DataTemplate>
    </Page.Resources>
        <StackPanel Background="Red">
        <ListBox  ItemTemplate="{StaticResource testTemplate}"
                 ItemsSource="{Binding Path=Statuses}"
                 ScrollViewer.CanContentScroll="False"
                 IsSynchronizedWithCurrentItem="True"
                 Height="200" 
                 />
        <Button Command="{Binding Path=DataContext.CopyCommand,
            RelativeSource={RelativeSource Mode=FindAncestor,
            AncestorType=Page},
            Converter={StaticResource CommandConverter},
            diagnostics:PresentationTraceSources.TraceLevel=High,
            Mode=TwoWay}" CommandParameter="hello" Content="Copy"/>
        <Button Command="{x:Static local:CustomCommands.MyCommand}" CommandParameter="MyCommand" Content="TestTest"/>
        <TextBlock Text="right click me to see what happend">
                        <TextBlock.ContextMenu>
                            <ContextMenu>
                                <MenuItem Command="{Binding Path=CopyCommand}" CommandParameter="From Main Page" Header="Copy"/>
                            </ContextMenu>
                        </TextBlock.ContextMenu>
        </TextBlock>
    </StackPanel>
</Page>
